﻿<Window x:Class="Passwords.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:utils="clr-namespace:Passwords.Utils"
        xmlns:models="clr-namespace:Passwords.Models"
        xmlns:views="clr-namespace:Passwords.Views"
        xmlns:vm="clr-namespace:Passwords.ViewModels"
        Title="{Binding BackupName, FallbackValue=Passwords}"  SnapsToDevicePixels="True" 
        Foreground="{DynamicResource AppForeground}"
        Width="850" Height="500" 
        MinWidth="{Binding MinWidth, FallbackValue=320}" MinHeight="380"
        WindowStyle="SingleBorderWindow"  FontFamily="Segoe UI" 
        ResizeMode="CanResize" mc:Ignorable="d"  Focusable="False"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        d:DesignHeight="564" d:DesignWidth="1039" Background="{DynamicResource AppWindowBackground}" >
    <Window.InputBindings>
        <KeyBinding Key="L" Modifiers="Alt" Command="{x:Static vm:Commands.LogoutCommand}"/>
        <KeyBinding Key="S" Modifiers="Alt" Command="{x:Static vm:Commands.ShowSettingsCommand}"/>
    </Window.InputBindings>
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo ProgressState="Normal" ProgressValue="30">
            <TaskbarItemInfo.ThumbButtonInfos>
                <ThumbButtonInfo  Description="Close" ImageSource="/Passwords;component/DarkImages/appbar.next.rest.png" IsEnabled="True" Click="ThumbButtonInfo_Click" />
            </TaskbarItemInfo.ThumbButtonInfos>
        </TaskbarItemInfo>
    </Window.TaskbarItemInfo>
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Styles/CompactPasswordsTemplate.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid Margin="15" Focusable="False">
        <Grid.Resources>
            <utils:BoolToVisibleConverter x:Key="boolToVisible"/>
            <utils:AppDisplayModeToVisibilityConverter x:Key="appModeToVis"/>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <views:LoginView Visibility="{Binding AppDisplayMode, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.Login}}" />
        <views:ChangePasswordView Visibility="{Binding AppDisplayMode, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.ChangePassword}}" />
        <views:SettingsView Visibility="{Binding AppDisplayMode, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.Settings}}" />
        <Grid DataContext="{Binding Data}">
            <Grid.Resources>
                <Style TargetType="ListBox" BasedOn="{StaticResource listBoxStyle}"/>
            </Grid.Resources>
            <views:PasswordsView Visibility="{Binding AppDisplayMode, FallbackValue=Collapsed, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.Passwords}}" />
            <views:EditPasswordView x:Name="editPasswordView"
                Visibility="{Binding AppDisplayMode, FallbackValue=Collapsed, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.EditPassword}}" />
            <views:EditCategoriesView Visibility="{Binding AppDisplayMode, FallbackValue=Collapsed, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.Categories}}" />
            <views:PasswordView
                Visibility="{Binding AppDisplayMode, FallbackValue=Collapsed, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.Password}}" />
        </Grid>
        <views:BackupView Visibility="{Binding AppDisplayMode, FallbackValue=Collapsed, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.BackupAndRestore}}" />
        <views:SynView Grid.Row="1" Margin="-15,0,-15,-15" VerticalAlignment="Bottom"/>
        <Border Grid.Row="1" Margin="-15,0,-15,-15" VerticalAlignment="Bottom" Background="{DynamicResource AppAccentBrush}" TextBlock.Foreground="White"
                Visibility="{Binding IsServiceFaulted, Converter={StaticResource boolToVisible}}">
            <TextBlock Text="{Binding ServiceError}" Margin="15,0" HorizontalAlignment="Left" />
        </Border>
        <!--<Button Content="?" Grid.RowSpan="9" Grid.ColumnSpan="9" VerticalAlignment="Top" HorizontalAlignment="Left" Style="{StaticResource textButtonStyle}" Command="{x:Static vm:Commands.AboutCommand}"/>-->

        <views:AboutView Visibility="{Binding AppDisplayMode, FallbackValue=Collapsed, Converter={StaticResource appModeToVis},ConverterParameter={x:Static models:AppDisplayMode.About}}" />
        <Grid.LayoutTransform>
            <ScaleTransform ScaleX="1" ScaleY="1"/>
            </Grid.LayoutTransform>

    </Grid>
</Window>
